package com.zzw.system.custom;

import com.zzw.common.utils.MD5;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

/** 自定义密码处理
 * @author zzw
 * @date 2023/4/25 11:17
 */

@Component
public class CustomMd5PasswordEncoder implements PasswordEncoder {
//    加密
    @Override
    public String encode(CharSequence rawPassword) {
        return MD5.encrypt(rawPassword.toString());
    }
//    匹配

    @Override
    public boolean matches(CharSequence rawPassword, String encodePassword) {

        return encodePassword.equals(MD5.encrypt(rawPassword.toString()));
    }
}
